package itsm.isperp.module.service.task;

import itsm.isperp.control.form.table.TreeTable;
import itsm.isperp.framework.data.domain.DataRequest;
import itsm.isperp.framework.service.TreeNodeService;
import itsm.isperp.framework.utils.TreeNodeUtils;
import itsm.isperp.framework.web.request.JqGridFilterRuleOp;
import itsm.isperp.framework.web.request.JqGridRequest;
import itsm.isperp.module.entity.task.TskInspectTemplate;
import itsm.isperp.module.repository.task.TskInspectTemplateMapper;

import java.lang.reflect.ParameterizedType;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

/**
 * 服务
 * 
 * @author lizx
 * @date 2015-11-05 12:28
 */
@Service
public class TskInspectTemplateService extends
		TreeNodeService<TskInspectTemplate> {

	@Autowired
	protected TskInspectTemplateMapper tskInspectTemplateMapper;

	@Override
	public TskInspectTemplateMapper getRepository() {
		return this.tskInspectTemplateMapper;
	}

	public List<TskInspectTemplate> getTree(String defId, boolean showRoot,
			String... selectColumns) {
		DataRequest request = new JqGridRequest()
				.setSelectColumns(selectColumns).isPageable(false)
				.setSort("order_num", Direction.ASC);

		List<TskInspectTemplate> tree = this.getRepository()
				.findAllByRequest(request).getContent();

		return TreeNodeUtils.parseAndAddRootFormList(TskInspectTemplate.class,
				tree, true);
	}

}
